//
//  RootViewController.m
//  UI_元旦豆瓣小集合
//
//  Created by dllo on 15/12/31.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "RootViewController.h"
#import "PB1TableViewCell.h"
#import "My1model.h"
#import "UIImageView+WebCache.h"
#import "SixViewController.h"


@interface RootViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, retain) UITableView *tableview;
@property (nonatomic, retain) NSMutableArray *allArr;
@property (nonatomic, retain) NSMutableArray *allData;

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"活动";
    self.tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    _tableview.delegate = self;
    _tableview.dataSource = self;
    [self.view addSubview:_tableview];
    [_tableview release];
   
    
    NSString *path = [[NSBundle mainBundle] pathForResource:@"activity" ofType:@"plist"];
    self.allData = [NSMutableArray arrayWithContentsOfFile:path];
    self.allArr = [[NSMutableArray alloc] init];
    for (NSDictionary *dic in _allData) {
        My1model *model = [My1model my1model];
        [model setValuesForKeysWithDictionary:dic];
        [_allArr addObject:model];
    }
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 220;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _allData.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    PB1TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[PB1TableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    My1model *model = _allArr[indexPath.row];
    cell.BView.image = [UIImage imageNamed:@"4.png"];
    cell.SView.image = [UIImage imageNamed:@"1.png"];
    cell.photoView.image = [UIImage imageNamed:@"10.png"];
    cell.OnView.image = [UIImage imageNamed:@"11.png"];
    cell.InView.image = [UIImage imageNamed:@"12.png"];
    [cell.DView sd_setImageWithURL:[NSURL URLWithString:model.image]];
    cell.title.text = model.title;
    cell.begin_time.text = model.begin_time;
    cell.address.text = model.address;
    cell.category_name.text = [NSString stringWithFormat:@"%@", model.category_name];
    cell.participant_count.text = [NSString stringWithFormat:@"感兴趣:%@", model.participant_count];
    cell.wisher_count.text = [NSString stringWithFormat:@"参加:%@", model.wisher_count];
    return cell;
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    SixViewController *Svc = [[SixViewController alloc] init];
    Svc.index = indexPath;
//    My1model *modele = _allArr[indexPath.row];
    Svc.jie = _allArr;
//    Svc.str = modele.title;
//    Svc.str = modele.begin_time;
//    Svc.str = modele.address;
//    Svc.str = modele.category_name;
//    Svc.str = modele.participant_count;
//    Svc.str = modele.wisher_count;
    
    [self.navigationController pushViewController:Svc animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
